
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
from django.utils.timezone import now


class UserProfile(AbstractUser):
    """
    用户
    """
    name = models.CharField(max_length=30, null=True, blank=True, verbose_name='姓名')
    birthday = models.DateField(null=True, blank=True, verbose_name='出生日期')
    mobile = models.CharField(max_length=11, verbose_name='手机')
    gender = models.CharField(max_length=11, choices=(('male', '男'), ('female', '女')), default='female', verbose_name='性别')

    class Meta:
        verbose_name = '用户'
        verbose_name_plural = '用户'

    def __str__(self):
        return super().username


class VerifyCode(models.Model):
    """
    短信验证码
    """
    code = models.CharField(max_length=10, verbose_name='验证码')
    mobile = models.CharField(max_length=11, verbose_name='手机')
    add_time = models.DateField(default=now, verbose_name='添加时间')


    class Meta:
        verbose_name = '验证码'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.code


class EmailVerifyCode(models.Model):
    """
    短信验证码
    """
    code = models.CharField(max_length=10, verbose_name='验证码')
    email = models.CharField(max_length=25, verbose_name='邮箱')
    add_time = models.DateField(default=now, verbose_name='添加时间')


    class Meta:
        verbose_name = '验证码'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.code